import akshare as ak
from typing import Dict

def get_stock_fundamentals(stock_code: str) -> Dict:
    """
    获取股票基本面数据
    :param stock_code: 股票代码（格式：sh600000）
    :return: 包含财务指标的字典
    """
    try:
        # 获取利润表
        income_df = ak.stock_financial_report_sina(stock=stock_code, symbol="利润表")
        # 获取资产负债表
        balance_df = ak.stock_financial_report_sina(stock=stock_code, symbol="资产负债表")
        
        return {
            "income_statement": income_df.head(5).to_dict(orient="records"),
            "balance_sheet": balance_df.head(5).to_dict(orient="records"),
        }
    except Exception as e:
        raise ValueError(f"数据获取失败: {str(e)}")